package com.neusoft.bizcore.notice.notification.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.neusoft.bizcore.notice.notification.dto.NoticeRecordDTO;
import com.neusoft.bizcore.notice.notification.service.NoticeRecordService;
import com.neusoft.bizcore.web.dto.result.PageResultDTO;
import com.neusoft.bizcore.web.dto.result.ResultDTO;
import com.neusoft.bizcore.web.dto.result.ResultListDTO;
import com.neusoft.bizcore.web.support.Searchable;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Api(tags = "所有通知记录")
@RestController
@RequestMapping(value = "/api/w/notification/record")
public class NoticeRecordController {
    @Autowired
    private NoticeRecordService noticeRecordService;

    @ApiOperation("查询所有")
    @GetMapping
    public ResultListDTO<NoticeRecordDTO> index(final Searchable searchable) {
        final List<NoticeRecordDTO> DTOs = this.noticeRecordService.findAll(searchable);
        final ResultListDTO<NoticeRecordDTO> result = ResultListDTO.success(DTOs);
        return result;
    }

    @ApiOperation("分页查询")
    @GetMapping("/p")
    public PageResultDTO<NoticeRecordDTO> search(final Pageable pageable, final Searchable searchable) {
        return PageResultDTO.success(this.noticeRecordService.search(pageable, searchable));
    }

    @ApiOperation("创建")
    @PostMapping("")
    public ResultDTO<NoticeRecordDTO> create(@RequestBody final NoticeRecordDTO dto) {
        final NoticeRecordDTO result = this.noticeRecordService.create(dto);
        return ResultDTO.success(result);
    }

    @ApiOperation("查看通知记录详情")
    @GetMapping("/{id}")
    public ResultDTO<NoticeRecordDTO> details(@PathVariable final Long id) {
        final NoticeRecordDTO dto = this.noticeRecordService.details(id);
        return ResultDTO.success(dto);
    }

    //    @ApiOperation("删除通知记录")
    //    @DeleteMapping("/{id}")
    //    public ResultDTO<Void> delete(@PathVariable final Long id) {
    //        this.noticeRecordService.delete(id);
    //        return ResultDTO.success();
    //    }

}
